<?php
use yii\helpers\Html;
use common\components\helpers\Fun;
use doumiaoduo\layer\LayerAsset;
LayerAsset::register($this);

use \common\components\extenders\MenuManage;
?>
<div class="yx-praise-list-box yx-praise-box yx-radius2 zx-min-height" id="toolbar" >
    <?= $this->renderFile('@app/views/layouts/toolbar.php'); ?>
    <div id="search-area" class="yx-bgf7f7f7 yx-radius5 zx-mg yx-function2 yx-pr0">
        <?= Html::beginForm(Fun::url(['characteristic/index']), 'get', ['enctype' => 'multipart/form-data']) ?>
        <?= \common\components\helpers\Search::textInput('goods_name', \Yii::$app->request->get('goods_name'), ['label'=>'课程名称','class' => 'search yx-width150 zx-lh24 yx-ml6']); ?>
        <?= \common\components\helpers\Search::submitButton('搜索',  ['id'=>'search-handle','class'=>"yx-search yx-radius2"]); ?>
        <?php Html::endForm() ?>
    </div>
  <div class="docs-main zx-mg">
      <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check"  data-tablesaw-mode="swipe" data-tablesaw-minimap >
       <thead>
            <tr class="yx-bgd2f6ec">
                <th><?=\Yii::t('zhtfrontend','课程名称');?></th>
                <th><?=\Yii::t('zhtfrontend','分类名称');?></th>
                <th><?=\Yii::t('zhtfrontend','老师');?></th>
                <th><?=\Yii::t('zhtfrontend','教室');?></th>
                <th><?=\Yii::t('zhtfrontend','上课时间');?></th>
                <th><?=\Yii::t('zhtfrontend','库存');?></th>
                <th><?=\Yii::t('zhtfrontend','价格');?></th>
                <th><?=\Yii::t('zhtfrontend','上下架');?></th>
                <th><?=\Yii::t('zhtfrontend','操作');?></th>
            </tr>
        </thead>
          <?php if($data):?>
               <?php foreach($data as $item):?>
                  <tr data-id="<?=$item['id']?>">
                      <td><?=$item['name']?></td>
                      <td><?=$item['cate_name']?></td>
                      <td><?=$item['teacherStr']?></td>
                      <td><?=$item['room_name']?></td>
                      <td><?=$item['class_time']?></td>
                      <td><?=$item['store']?></td>
                      <td><?=$item['price']?></td>
                      <td><?=$item['is_shelve']?></td>
                      <td><?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('characteristic','remove',false,['rel'=>'remove','class' => 'btn yx-d-card yx-bgb5b5b5 yx-width67 yx-radius2 yx-mr5','data'=>['id'=>$item['id']]]);?></td>
                  </tr>
                  <?php endforeach?>
         <?php endif?>
    </table>
      <div style="text-align: right"><?= common\components\widgets\GoPager::widget(['pagination' => $pages]) ?></div>
  </div>
</div>
<?php
$js=<<<JS
 $('td .shelve').css({"color":"#464656","cursor":"default"});
 $('td .shelve').attr('title','');
 layer.config({
        extend: ['skin/customskin/style.css']//加载您的扩展样式
    });
    $(document).on('click','a[rel=remove]',function(){
        var url = $(this).data('url');
        var parent = $(this).parent();
        layer.confirm('确定要移除么？',function(){
                $.ajax({
                 url:url,
                 type:'get',
                 dataType:'json',
                 beforeSend:function(){
                    layer.load(0, { shade: [0.5, '#393D49'] });
                 },
                 complete:function(){
                  layer.close(layer.load(0, { shade: [0.5, '#393D49'] }));  
                },
                success:function(data){
                      layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000}); 
                      window.location.reload();
                }
                
             });
        });
        
    });
JS;
$this->registerJs($js);
?>



